//
//  CustomNavigationCoutroller.m
//  ReceiveTask
//
//  Created by WangZhenyu on 2018/11/21.
//  Copyright © 2018 WangZhenyu. All rights reserved.
//

#import "CustomNavigationCoutroller.h"
#import "GlobalFunction.h"
#import "CustomerNavigationBar.h"

@implementation CustomNavigationCoutroller

- (instancetype)init{
    if (self = [super initWithNavigationBarClass:[CustomerNavigationBar class] toolbarClass:nil]) {
        self.fd_fullscreenPopGestureRecognizer.enabled = NO;
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        if (@available(iOS 15.0, *)) {
            UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
            // 背景色
            appearance.backgroundColor = ThemeColor;
            // 去掉半透明效果
            appearance.backgroundEffect = nil;
            // 标题字体颜色及大小
            appearance.titleTextAttributes = @{
                NSForegroundColorAttributeName : [UIColor whiteColor],
                NSFontAttributeName : [UIFont systemFontOfSize:18.0 weight:UIFontWeightMedium],
            };
            // 设置导航栏下边界分割线透明
            appearance.shadowImage = [[UIImage alloc] init];
            // 去除导航栏阴影（如果不设置clear，导航栏底下会有一条阴影线）
            appearance.shadowColor = [UIColor clearColor];
            // standardAppearance：常规状态, 标准外观，iOS15之后不设置的时候，导航栏背景透明
            self.navigationBar.standardAppearance = appearance;
            // scrollEdgeAppearance：被scrollview向下拉的状态, 滚动时外观，不设置的时候，使用标准外观
            self.navigationBar.scrollEdgeAppearance = appearance;
        } else {
            [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18.0 weight:UIFontWeightMedium]}];
            self.navigationBar.tintColor = [UIColor whiteColor];
            self.navigationBar.barStyle = UIBarStyleDefault;
            [self.navigationBar setShadowImage:getColorToImage([UIColor clearColor])];
            [self.navigationBar setTranslucent:YES];
            [self.navigationBar lt_setBackgroundImage:getColorToImage(ThemeColor)];
        }
    }
    return self;
}


@end
